///**
//* @CopyRight tstudy.com.cn
//* @author wuyahui
//* @E-mail wuyahui0124505@163.com
//* @version 1.0.0
//* @Date  2015年4月3日 下午1:03:40
//*/
//package com.tstudy.laoshibang.group;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import org.androidannotations.annotations.AfterViews;
//import org.androidannotations.annotations.Click;
//import org.androidannotations.annotations.EFragment;
//import org.androidannotations.annotations.ViewById;
//import org.apache.http.Header;
//
//import com.handmark.pulltorefresh.library.PullToRefreshBase;
//import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
//import com.handmark.pulltorefresh.library.PullToRefreshListView;
//import com.tstudy.laoshibang.R;
//import com.tstudy.laoshibang.base.BaseActivity;
//import com.tstudy.laoshibang.base.BaseApplication;
//import com.tstudy.laoshibang.base.BaseFragment;
//import com.tstudy.laoshibang.base.BaseOnScrollListener;
//import com.tstudy.laoshibang.base.BaseOnScrollListener.FirstPositionCallBack;
//import com.tstudy.laoshibang.base.BaseOnScrollListener.LoadMoreCallBack;
//import com.tstudy.laoshibang.base.CONSTANT;
//import com.tstudy.laoshibang.base.CONSTANT.LoadType;
//import com.tstudy.laoshibang.base.HttpManager;
//import com.tstudy.laoshibang.custom.RoundImageView;
//import com.tstudy.laoshibang.group.GroupAdapter.AdapterCallBack;
//import com.tstudy.laoshibang.mode.Group;
//import com.tstudy.laoshibang.mode.request.Conds;
//import com.tstudy.laoshibang.mode.response.GroupDetailResponse;
//import com.tstudy.laoshibang.mode.response.GroupListResponse;
//import com.tstudy.laoshibang.utils.CommonUtil;
//import com.tstudy.laoshibang.utils.LogUtil;
//
//import android.annotation.SuppressLint;
//import android.os.Bundle;
//import android.os.Handler;
//import android.support.v4.app.Fragment;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.ImageView;
//import android.widget.ListView;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//import de.greenrobot.event.EventBus;
//@SuppressLint("InflateParams")
//@EFragment(R.layout.group_list)
//public class GroupListFragment extends BaseFragment{
//	final static String TAG = "group_list";
//	public GroupListFragment() {
//		super();
//	}
//	
//	@ViewById(R.id.group_list_root)
//	RelativeLayout mRootLayout;
//	
//	@ViewById(R.id.group_list_progress)
//	RelativeLayout mProgressLayout;
//	
//	@ViewById(R.id.group_list_list)
//	PullToRefreshListView mPullToRefreshListView;
//	
//	@ViewById(R.id.group_list_title)
//	TextView mTitleTxt;
//
//	BaseOnScrollListener mBaseOnScrollListener;
//	LoadType mLoadType;
//	
//	boolean mIsFirstLoad = true;
//	Handler mHandler;
//	LayoutInflater mInflater;
//	GroupAdapter mMyGroupAdapter;
//	int mCurrentPosition = 0;
//	List<Group> mMyGroups = new ArrayList<Group>();
//
//	public static void add(int containerViewId) {
//		Bundle args = new Bundle();
//		args.putInt(CONSTANT.ARGS.FRAGMENT_ID, containerViewId);
//		Fragment fragment = Fragment.instantiate(BaseApplication.mContext,GroupListFragment_.class.getName(),args);
//		((BaseActivity)BaseApplication.mCurrentActivity).add(containerViewId,fragment,TAG);	
//	}
//	@Override
//	public void onCreate(Bundle savedInstanceState) {
//		mHandler = new Handler();
//		EventBus.getDefault().register(this);
//		super.onCreate(savedInstanceState);
//	}
//	@Override
//	public View onCreateView(LayoutInflater inflater, ViewGroup container,
//			Bundle savedInstanceState) {
//		mInflater = inflater;
//		super.onCreateView(inflater, container, savedInstanceState);
//		LogUtil.d("--mBaseLayout==" + mRootLayout);
//		mIsFirstLoad = mRootLayout == null;
//		if (mRootLayout != null) {
//			((ViewGroup) mRootLayout.getParent()).removeAllViews();
//		}
//		return mRootLayout;
//	}
//	
//	@AfterViews
//	public void initView(){
//		if (mIsFirstLoad) {
//			mRootLayout.setOnClickListener(null);
//			mMyGroupAdapter = new GroupAdapter(true);
//			mPullToRefreshListView.setAdapter(mMyGroupAdapter);
//			mMyGroupAdapter.setAdatperCallBack(new AdapterCallBack() {
//				@Override
//				public void onViewClick(String groupId, int position) {
//					GroupProfileFragment.add(mFragmentId, groupId);
//				}
//				@Override
//				public void onAddClick(Group group, int position) {
//					groupApply(group, position);
//				}
//			});
//			mLoadType = LoadType.load_first;
//			mHandler.postDelayed(new Runnable() {
//				@Override
//				public void run() {
//					getGroupList();
//				}
//			}, CONSTANT.LOAD_DATA_DELAY_TIME);
//			mBaseOnScrollListener = new BaseOnScrollListener(new LoadMoreCallBack() {
//				@Override
//				public void loadMore() {
//					mPullToRefreshListView.startLoadMore();
//					mLoadType = LoadType.load_more;
//					getGroupList();
//				}
//			});
//			mBaseOnScrollListener.setFirstPositionCallBack(new FirstPositionCallBack() {
//				@Override
//				public void firstPosition(int firstPosition) {
//					mCurrentPosition = firstPosition;
//				}
//			});
//			mPullToRefreshListView.setOnScrollListener(mBaseOnScrollListener);
//			mPullToRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
//				@Override
//				public void onRefresh(PullToRefreshBase<ListView> refreshView) {
//					mLoadType = LoadType.load_refresh;
//					getGroupList();
//				}
//			});
//		}
//	}
//	
//	
//	
//	@Click({R.id.group_list_back})
//	public void actionClick(View view){
//		switch (view.getId()) {
//		case R.id.group_list_back:
//			backAction(mFragmentId);
//			break;
//		default:
//			break;
//		}
//	}
//	
//	RelativeLayout mHeaderLayout;
//	RoundImageView mAvatar;
//	ImageView mTheme;
//	TextView mName;
//	
//	private void getGroupList(){
//		if (mIsLoading) {
//			return ;
//		}
//		if (mLoadType == LoadType.load_more) {
//			start += pageSize;
////			limit += pageSize;
//		}else{
//			start = 0;
//			limit = pageSize;
//		}
//		mIsLoading = true;
//		BaseListJsonHandler<GroupListResponse> response = new BaseListJsonHandler<GroupListResponse>() {
//			public void onStart() {
//				if (mLoadType == LoadType.load_first) {
//					showProgressBar(mProgressLayout);
//				}
//			}
//			@Override
//			public void onSuccess(int statusCode, Header[] headers,
//					String rawJsonResponse, GroupListResponse response) {
//				super.onSuccess(statusCode, headers, rawJsonResponse, response);
//				if (CommonUtil.responseSuccess(response)) {
//					if (mLoadType == LoadType.load_more) {
//						if (mMyGroups.size() == response.getData().getCount()) {
//							mBaseOnScrollListener.mIsEnd = true;
//						}
//					}else{
//						mMyGroups.clear();
//					}
//					if (response.getData() != null) {
//						List<Group> list = response.getData().getList();
//						if (list != null) {
//							mMyGroups.addAll(list);
//						}
//						mMyGroupAdapter.setData(mMyGroups);
//					}
//				}else{
//					BaseApplication.showToast(response.getErrMsg());
//					
//				}
//				afterLoading();
//			}
//			@Override
//			public void onFailure(int statusCode, Header[] headers,
//					Throwable throwable, String rawJsonData,
//					GroupListResponse errorResponse) {
//				afterLoading();
//				super.onFailure(statusCode, headers, throwable, rawJsonData, errorResponse);
//			}
//			@Override
//			protected GroupListResponse parseResponse(String rawJsonData, boolean isFailure)
//					throws Throwable {
//				return mGson.fromJson(rawJsonData,GroupListResponse.class);
//			}
//		};
//		List<Conds> conds = new ArrayList<Conds>();
//		HttpManager.getInstance().getGroupList(BaseApplication.mUserNo, start, limit, null, conds, response);
//	}
//	
//	private void groupApply(final Group group,final int position){
//		if (mIsLoading) {
//			return ;
//		}
//		mIsLoading = true;
//		BaseListJsonHandler<GroupDetailResponse> response = new BaseListJsonHandler<GroupDetailResponse>() {
//			public void onStart() {
//				if (mLoadType == LoadType.load_first) {
//					showProgressBar(mProgressLayout);
//				}
//			}
//			@Override
//			public void onSuccess(int statusCode, Header[] headers,
//					String rawJsonResponse, GroupDetailResponse response) {
//				super.onSuccess(statusCode, headers, rawJsonResponse, response);
//				if (CommonUtil.responseSuccess(response)) {
//					if (response.data != null) {
//						mMyGroups.get(position).status = response.data.status;
//						mMyGroupAdapter.setData(mMyGroups);
//					}else{
//						BaseApplication.showToast(response.getErrMsg());
//					}
//				}
//				afterLoading();
//			}
//			@Override
//			public void onFailure(int statusCode, Header[] headers,
//					Throwable throwable, String rawJsonData,
//					GroupDetailResponse errorResponse) {
//				afterLoading();
//				super.onFailure(statusCode, headers, throwable, rawJsonData, errorResponse);
//			}
//			@Override
//			protected GroupDetailResponse parseResponse(String rawJsonData, boolean isFailure)
//					throws Throwable {
//				return mGson.fromJson(rawJsonData,GroupDetailResponse.class);
//			}
//		};
//		HttpManager.getInstance().groupApply(BaseApplication.mUserNo, group.groupId, "", response);
//	}
//	
//	public void onEventMainThread(Object object) {//申请成功后更新列表
//		mLoadType = LoadType.load_first;
//	}
//
//	public void afterLoading(){
//		mIsLoading = false;
//		hideProgressBar(mProgressLayout);
//		if(mLoadType == LoadType.load_more){
//			if (mBaseOnScrollListener.mIsEnd) {
//				mPullToRefreshListView.endLoadMore(BaseApplication.getResString(R.string.community_no_more_data));
//			}else{
//				mPullToRefreshListView.stopLoadMore();
//			}
//		}
//		if(mPullToRefreshListView != null){
//			new Handler().postDelayed(new Runnable() {
//				@Override
//				public void run() {
//					if(mPullToRefreshListView != null){
//						mPullToRefreshListView.onRefreshComplete();
//						LogUtil.d("--onRefreshComplete afterloading");
//					}
//				}
//			}, 1000);
//		}
//	
//	}
//	@Override
//	public void clear() {
//	}
//	
//	@Override
//	public void onDestroy() {
//		EventBus.getDefault().unregister(this);
//		super.onDestroy();
//	}
//
//	@Override
//	public void initArgs(Bundle args) {
//		if (args != null) {
//			mFragmentId = args.getInt(CONSTANT.ARGS.FRAGMENT_ID);
//		}
//	}
//
//}
